package com.liwei;

import javax.servlet.http.HttpServletRequest;

import org.easymock.MockControl;
import org.jmock.MockObjectTestCase;

public class TestMyClassEasyMock extends MockObjectTestCase {

	private MockControl control;

	private HttpServletRequest mockRequest;

	private MyClass myclass;

	public void setUp() {

		myclass = new MyClass();

		// 创建一个Mock HttpServletRequest的MockControl对象
		control = MockControl.createControl(HttpServletRequest.class);

		// 获取一个Mock HttpServletRequest对象
		mockRequest = (HttpServletRequest) control.getMock();
		control.setReturnValue("kongxx", 1, 1);
		control.replay();
	}

	public void tearDown() {
	}

	public void testGetName() {
		control.replay();

		assertNotNull(myclass.getName(mockRequest));
		assertEquals("kongxx", mockRequest.getParameter("name"));
	}

}